package com.houweishi.module.typeconfig.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.typeconfig.domain.TypeConfig;
import com.houweishi.module.typeconfig.service.ITypeConfigService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 垃圾分类-配置Controller
 * 
 * @author houweishi
 * @date 2023-03-10
 */
@RestController
@RequestMapping("/module/typeconfig")
public class TypeConfigController extends BaseController
{
    @Autowired
    private ITypeConfigService typeConfigService;

    /**
     * 查询垃圾分类-配置列表
     */
    @PreAuthorize("@ss.hasPermi('module:typeconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(TypeConfig typeConfig)
    {
        startPage();
        List<TypeConfig> list = typeConfigService.selectTypeConfigList(typeConfig);
        return getDataTable(list);
    }

    /**
     * 导出垃圾分类-配置列表
     */
    @PreAuthorize("@ss.hasPermi('module:typeconfig:export')")
    @Log(title = "垃圾分类-配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TypeConfig typeConfig)
    {
        List<TypeConfig> list = typeConfigService.selectTypeConfigList(typeConfig);
        ExcelUtil<TypeConfig> util = new ExcelUtil<TypeConfig>(TypeConfig.class);
        util.exportExcel(response, list, "垃圾分类-配置数据");
    }

    /**
     * 获取垃圾分类-配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:typeconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(typeConfigService.selectTypeConfigById(id));
    }

    /**
     * 新增垃圾分类-配置
     */
    @PreAuthorize("@ss.hasPermi('module:typeconfig:add')")
    @Log(title = "垃圾分类-配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TypeConfig typeConfig)
    {
        return toAjax(typeConfigService.insertTypeConfig(typeConfig));
    }

    /**
     * 修改垃圾分类-配置
     */
    @PreAuthorize("@ss.hasPermi('module:typeconfig:edit')")
    @Log(title = "垃圾分类-配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TypeConfig typeConfig)
    {
        return toAjax(typeConfigService.updateTypeConfig(typeConfig));
    }

    /**
     * 删除垃圾分类-配置
     */
    @PreAuthorize("@ss.hasPermi('module:typeconfig:remove')")
    @Log(title = "垃圾分类-配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(typeConfigService.deleteTypeConfigByIds(ids));
    }
}
